package com.yangrui.app.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import springfox.documentation.RequestHandler;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
@PropertySource("classpath:application.properties")
public class SwaggerConfig {

    @Value("${server.port}")
    int port;


    public ApiInfo getSwaggerInfo() {

        return new ApiInfoBuilder().title("课堂测试").
                description("课堂测试").
                version("1.0").
                contact(new Contact("杨瑞", "http://www.yangrui.com", "1821485123@qq.com")).
                build();
    }

    @Bean
    public Docket docketA(){
         return new Docket(DocumentationType.SWAGGER_2).
                groupName("A").
                apiInfo(getSwaggerInfo()).
                select().
                apis(RequestHandlerSelectors.basePackage("com.yangrui.app.controller")).
                paths(PathSelectors.ant("/api/v1/**"))
                 .build();
    }
}
